var isIndexPageGoBack;
var _isVipSubscriptIndexTimeout;
(function (g, h) {
	var c = function () {
		// box
		function b(b, d, c, g, opt, l, h) {// opt : {name:""}
			this.opt = opt || {};
			this.marDirection = "left";
			this.curIndex = 0;
			this.curPage = 1;
			this.totalEle = 0;
			this.totalPage = 1;
			this.id = void 0;
			this.byjson=this.opt.byjson;// 插入 将当个组件的byjson 定义
			this.X = b || 0;
			this.Y = d || 0;
			this.dirs = c || [-1, -1, -1, -1];
			this.eles = g || [];
			this.eleFocusAttr = l || "className:aim aimon";
			this.eleBlurAttr = h || "className:aim";
			this.autoCycleFlip = this.autoVerticalFlip = this.autoHorizontalFlip = !1;
			this.Arrangement = "X";
			this.lastLineTurn = !0;
			this.pageTurnKeep = this.focusLast = !1;
			this.scrollArg = [];
			this.pageTurnFlag = 0;
			this.canSlide = !1;
			this.slideEle = void 0;
			this.slideType = "auto";
			this.slideOffset = [0, 0, 0, 0];
			this.topStep = this.leftStep = 0;
			this.IOIsRecordArr = this.opt.IOIsRecordArr || [!1, !1, !1, !1];
			this.IORecordIndexArr = this.opt.IORecordIndexArr === undefined ? [0, 0, 0, 0] : +this.opt.IORecordIndexArr;
			if (typeof this.IORecordIndexArr == "number" && this.IORecordIndexArr > 0) {
				this.curIndex = this.IORecordIndexArr
			}
			this.IORecordAttrArr = ["className:aim aimin", "className:aim aimin", "className:aim aimin", "className:aim aimin"];
			this.darkFlag = !1;
			this.darkPage = 1;
			this.darkIndex = 0;
			this.haveDark = false;
			this.darkFocusAttr = "className:aim aimon";
			this.darkBlurAttr = "className:aim aimin";
			this.focusEventRetry = function () {
				if (Wrapper.curBoxId == this.id) {
					this.focusEvent(this.eles[this.curIndex].vod);
				}
			}
			this.addClass = function (index, classes) {
				for (let i = 0; i < this.eles.length; i++) {
					const element = this.eles[i];
					JQ("#" + element.htmlEleId).removeClass(classes)
				}
				JQ("#" + this.eles[index].htmlEleId).addClass(classes)
			}
			this.removeClass = function (index, classes) {
				JQ("#" + this.eles[index].htmlEleId).removeClass(classes)
			}
			this.upEvent = function () { };

			this.downEvent = function () { };

			this.leftEvent = function () { };

			this.rightEvent = function () { };

			this.boxOkEvent = function () { };

			this.focusEvent = function () { };

			this.blurEvent = function () { };

			this.boxPageTurnEvent = function () { };

			this.boxOutEvent = function () { };

			this.boxInEvent = function () { };
			this.getCurEle = function () {
				return this.eles[this.curIndex]
			}
			this.setIOIsRecord = function (b) {
				this.darkFocusAttr = "className:aim aimon";
				this.darkBlurAttr = "className:aim aimin";
				this.IORecordIndexArr = b;
				this.eles[b].changeAttr(this.darkBlurAttr)
			};
			this.setDarkfocus = function (a, b) {
				this.darkFlag = !0;
				this.darkPage = a;
				this.darkIndex = b;
				this.darkFocusAttr = "className:aim aimon";
				this.darkBlurAttr = "className:aim aimin";
				this.curPage === a && (this.eles[b].focusAttr = this.darkFocusAttr, this.eles[b].blurAttr = this.darkBlurAttr, this.eles[b].changeAttr(this.darkBlurAttr));
        if (this.opt.scrollEle) Wrapper.moveScroll(JQ(this.opt.scrollEle), this.getCurEle().htmlEleId, false, {
					isParallel: this.opt.isParallel,
					scrollDir: this.opt.scrollDir,
					scrollRelationEle: null,
					isBox: true
				})
			};

			this.changeDarkFocus = function () {
				this.curPage === this.darkPage ? (this.eles[this.darkIndex].focusAttr = this.darkFocusAttr, this.eles[this.darkIndex].blurAttr = this.darkBlurAttr, this.eles[this.darkIndex].changeAttr(this.darkBlurAttr)) : (this.eles[this.darkIndex].focusAttr = this.eleFocusAttr, this.eles[this.darkIndex].blurAttr = this.eleBlurAttr, this.eles[this.darkIndex].changeAttr(this.eleBlurAttr));
			};

			this.setSlide = function (a, b, d, c, e) {
				this.canSlide = !0;
				this.slideEle = a;
				this.slideType = b;
				this.leftStep = d || this.topStep;
				this.topStep = c || this.topStep;
				this.slideOffset = e || this.slideOffset;
			};

			this.changeFocus = function (b, d) {
				// d?(this.curIndex=b,this.focusEvent()):this.blurEvent();
				if (d) {
					this.curIndex = b;// b 是index值
					if (this.eles[this.curIndex] && this.eles[this.curIndex].vod) {
						this.focusEvent(this.eles[this.curIndex].vod);
					} else {
						this.focusEvent()
					}

					try {
						// 自动滚动
						if ("undefined" !== typeof this.pageScroll && this.pageScroll) {
							var _psIsLastLine = false;

							if (this.id + 1 == Wrapper.boxes.length) {
								if (this.X < 2) {
									_psIsLastLine = true;
								} else {
									if (this.curIndex >= (this.X - 1) * this.Y) {
										_psIsLastLine = true;
									} else {
										_psIsLastLine = false;
									}
								}
							}

							var objX = {
								"curId": "box" + this.id + "_" + this.curIndex,
								"selfWidth": "undefined" !== typeof this["width_line"] ? this["width_line"] : document.querySelector("#" + this.eles[this.curIndex].htmlEleId).offsetWidth,
								"totalele": Wrapper.boxes[this.id].totalEle,
								"type": "undefined" !== typeof this["type"] ? this["type"] : ''
							};
							var obj = {
								"isLastBox": _psIsLastLine,
								"curId": "box" + this.id + "_" + this.curIndex,
								"hasTitle": this.hasTitle && this.X > 1 && this.curIndex < this.Y,
								"selfHeight": "undefined" !== typeof this["height_line"] ? this["height_line"] : document.querySelector("#" + this.eles[this.curIndex].htmlEleId).offsetHeight
							};

							if ("undefined" !== typeof ps && "function" === typeof ps.scrollX) {
								ps.scrollX(objX);
							}

							if ("undefined" !== typeof ps && "function" === typeof ps.scrollY) {
								ps.scrollY(obj);
							}
						}
					} catch (error) { }
				} else {
					if (this.eles[this.curIndex] && this.eles[this.curIndex].vod) {
						this.blurEvent(this.eles[this.curIndex].vod);
					} else {
						this.blurEvent()
					}
				}

				if (this.canSlide) {
					if (d) {
						var c = this.eles[b].htmlEle;
						c || (c = a(this.eles[b].htmlEleId));

						if (null != c && this.slideEle) {
							var e = 0,
								f = 0;
							"auto" === this.slideType ? (e = this.getAbsPoint(c).x, f = this.getAbsPoint(c).y) : "manual" === this.slideType && (e = this.slideOffset[0], f = this.slideOffset[1], "X" === this.Arrangement ? (e += this.curIndex % this.Y * this.leftStep, f += this.topStep * Math.floor(this.curIndex / this.Y)) : "Y" === this.Arrangement && (e += this.leftStep * Math.floor(this.curIndex / this.X), f += this.curIndex % this.X * this.topStep));
							this.slideEle.style.cssText = "left:" + e + "px;top:" + f + "px;width:" + (c.offsetWidth + this.slideOffset[2]) + "px;height:" + (c.offsetHeight + this.slideOffset[3]) + "px;transitionDuration:" + this.slideEle.style.transitionDuration + ";-webkit-transition-duration:" + this.slideEle.style.transitionDuration + ";-moz-transition-duration:" + this.slideEle.style.transitionDuration + ";-o-transition-duration:" + this.slideEle.style.transitionDuration;
							"none" === this.slideEle.style.display && (this.slideEle.style.display = "block");
						}
					}

					this.eles[b].toggleFocusEvent(d);
					// this.eles[b].marqueeScrollEvent(d);
				} else this.eles[b].changeFocus(d);
			};

			this.move = function (a) {// 同一个盒子下的移动
				var b = this.eles[this.curIndex]; -
					1 != b.moveDirs[a] && b.moveDirs[a] < this.totalEle && (this.changeFocus(this.curIndex, !1), this.curIndex = b.moveDirs[a], this.changeFocus(this.curIndex, !0));
			};

			this.ok = function () {
				var res = this.boxOkEvent(this.eles[this.curIndex].vod);
				this.darkFlag && (this.curPage === this.darkPage && (this.eles[this.darkIndex].focusAttr = this.eleFocusAttr, this.eles[this.darkIndex].blurAttr = this.eleBlurAttr, this.eles[this.darkIndex].changeAttr(this.eleBlurAttr)), this.darkIndex = this.curIndex, this.darkPage = this.curPage, this.eles[this.darkIndex].focusAttr = this.darkFocusAttr, this.eles[this.darkIndex].blurAttr = this.darkBlurAttr, this.canSlide ? this.eles[this.darkIndex].changeAttr(this.darkBlurAttr) : this.eles[this.darkIndex].changeAttr(this.darkFocusAttr));
				this.eles[this.curIndex].ok();
				return res;
			};

			this.boxIn = function (a, b) {// a是索引 b是方向
				Wrapper.curBoxId = this.id;
				var d = a;
				this.totalEle && d > this.totalEle - 1 && (d = this.totalEle - 1);
				var c = (b + 2) % 4;
				if (this.IOIsRecordArr === true) {
					if (this.IORecordIndexArr[c] !== undefined) {
						d = this.IORecordIndexArr[c]
					} else {
						d = this.IORecordIndexArr
					}
				} else if (this.IOIsRecordArr[c] && this.IORecordIndexArr[c] != undefined) {
					d = this.IORecordIndexArr[c]
				}
				this.changeFocus(d, !0);
				this.boxInEvent(a, b);
			};

			this.boxOut = function (a, b) {
				var d = a;
				this.totalEle && d > this.totalEle - 1 && (d = this.totalEle - 1);
				if (this.IOIsRecordArr === true || this.IOIsRecordArr[b]) {
					if (this.haveDark == true) {
						this.IORecordIndexArr[b] = this.darkIndex;
					} else if (this.IOIsRecordArr === true) {
						this.IORecordIndexArr = d
					} else if (this.IORecordIndexArr[b] != undefined) {
						this.IORecordIndexArr[b] = d;
					}
					var className;
					if (typeof this.IORecordAttrArr == "string") {
						className = this.IORecordAttrArr
					} else {
						className = this.IORecordAttrArr[b]
					}
					if (className) {
						this.eles[d].changeAttr(className);
						this.eles[d].toggleFocusEvent(!1);
						this.eles[d].marqueeScrollEvent(!1);
						if (this.eles[this.curIndex] && this.eles[this.curIndex].vod) {
							this.blurEvent(this.eles[this.curIndex].vod);
						} else {
							this.blurEvent()
						}
						// this.changeFocus(d, !1)// 找到一个bug
					} else {
						this.changeFocus(d, !1)
					}

				} else this.changeFocus(d, !1);

				this.boxOutEvent(a, b);
			};

			this.pageTurn = function (a) {
				if (1 < this.totalPage) {
					var b = this.curPage + a;

					if (b > this.totalPage) {
						if (this.autoCycleFlip) {
							b = 1;
						} else {
							return;
						}
					} else if (1 > b) {
						if (this.autoCycleFlip) {
							b = this.totalPage;
						} else {
							return;
						}
					}

					this.curPage = b;
					this.pageTurnFlag = a;
					this.boxPageTurnEvent(a);
				}
			};

			this.pageTurnEnd = function () {
				if (0 !== this.pageTurnFlag) {
					this.darkFlag && this.changeDarkFocus();
					this.changeFocus(this.curIndex, !1);
					var a = 0;
					1 === this.pageTurnFlag ? a = 0 : -1 === this.pageTurnFlag && (a = this.totalEle - 1);
					if (this.pageTurnKeep) {
						if (this.autoVerticalFlip) {
							if ("X" === this.Arrangement) {
								var a = this.curIndex % this.Y,
									b = (this.totalEle - 1) % this.Y,
									d = Math.ceil(this.totalEle / this.Y);
								1 === this.pageTurnFlag ? a < this.totalEle ? this.changeFocus(a, !0) : this.changeFocus(this.totalEle - 1, !0) : a <= b ? this.changeFocus((d - 1) * this.Y + a, !0) : this.changeFocus(this.totalEle - 1, !0);
							} else "Y" === this.Arrangement && (a = Math.ceil((this.curIndex + 1) / this.X), b = Math.ceil(this.totalEle / this.X), 1 === this.pageTurnFlag ? b < a ? this.changeFocus((b - 1) * this.X, !0) : this.changeFocus((a - 1) * this.X, !0) : b <= a ? this.changeFocus(this.totalEle - 1, !0) : this.changeFocus(a * this.X - 1, !0));
						} else this.autoHorizontalFlip ? "X" === this.Arrangement ? (a = Math.ceil((this.curIndex + 1) / this.Y), b = Math.ceil(this.totalEle / this.Y), 1 === this.pageTurnFlag ? b < a ? this.changeFocus((b - 1) * this.Y, !0) : this.changeFocus((a - 1) * this.Y, !0) : b <= a ? this.changeFocus(this.totalEle - 1, !0) : this.changeFocus(a * this.Y - 1, !0)) : "Y" === this.Arrangement && (a = this.curIndex % this.X, b = (this.totalEle - 1) % this.X, d = Math.ceil(this.totalEle / this.X), 1 === this.pageTurnFlag ? a < this.totalEle ? this.changeFocus(a, !0) : this.changeFocus(this.totalEle - 1, !0) : a <= b ? this.changeFocus((d - 1) * this.X + a, !0) : this.changeFocus(this.totalEle - 1, !0)) : this.changeFocus(a, !0);
					} else this.changeFocus(a, !0);
				}
			};

			this.setMoveArray = function () {
				for (var a = arguments.length, b = 0; b < a && 4 > b; b++) {
					var d = arguments[b];
					if ("string" === typeof d && "-1" !== d)
						for (var d = d.split(","), c = d.length, e = 0; e < c; e++) {
							var f = d[e].split("-");
							this.eles[f[0]].moveDirs[b] = f[1];
						}
				}
			};

			this.setBoxDir = function (a, b) {
				var d = this.dirs[a],
					c = this.eles.length;
				this.dirs[a] = b;

				for (var e = 0; e < c; e++) {
					var f = this.eles[e].moveDirs[a]; -
						1 != f.indexOf(">") && 0 === f.indexOf(d) && (this.eles[e].moveDirs[a] = b + ">0");
				}
			};

			this.setBoxCircleEle = function (a) {
				"X" === a ? (this.eles[0].moveDirs[1] = this.eles.length - 1, this.eles[this.eles.length - 1].moveDirs[3] = 0) : "Y" === a && (this.eles[0].moveDirs[0] = this.eles.length - 1, this.eles[this.eles.length - 1].moveDirs[2] = 0);
			};

			this.setViewArrangement = function (a) {
				var b = this.X,
					d = this.Y,
					c = this.dirs,
					e = this.eles.length;
				this.Arrangement = a;
				if ("X" === a)
					for (a = 0; a < e; a++) {
						var f = [0 > a - d ? -1 === c[0] ? -1 : c[0] + ">0" : a - d, 0 === a % d ? -1 === c[1] ? -1 : c[1] + ">0" : a - 1, a + d > b * d - 1 ? -1 === c[2] ? -1 : c[2] + ">0" : a + d, a % d === d - 1 ? -1 === c[3] ? -1 : c[3] + ">0" : a + 1];
						this.eles[a].moveDirs = f;
					} else if ("Y" === a)
					for (a = 0; a < e; a++) {
						f = [0 === a % b ? -1 === c[0] ? -1 : c[0] + ">0" : a - 1, 0 > a - b ? -1 === c[1] ? -1 : c[1] + ">0" : a - b, a % b === b - 1 ? -1 === c[2] ? -1 : c[2] + ">0" : a + 1, a + b > b * d - 1 ? -1 === c[3] ? -1 : c[3] + ">0" : a + b], this.eles[a].moveDirs = f;
					}
			};

			this.clearEles = function () {
				for (var a = this.eles.length, b = 0; b < a; b++) {
					this.eles[b].htmlEle = null, this.eles[b].scrollEle = null;
				}
			};

			this.setScrollEvent = function () {
				0 < arguments.length ? this.scrollArg = arguments : 0 < this.scrollArg.length && (arguments = this.scrollArg);
				var b = arguments[0] || "",
					d = arguments[1] || 0,
					c = arguments[arguments.length - 1];
				if (2 < arguments.length)
					if ("boolean" === typeof arguments[2])
						for (var e = this.eles.length, f = 0; f < e; f++) {
							a(b + f) && (this.eles[f].scrollId = b + f, this.eles[f].scrollText = a(b + f).innerHTML, this.eles[f].scrollCutStr = Util.getCutedStr(this.eles[f].scrollText, parseInt(d), c), this.eles[f].marqueeScrollEvent(!1));
						} else if (Util.isArray(arguments[2]))
						for (e = arguments[2].length, f = 0; f < e; f++) {
							var g = arguments[2][f];
							a(b + g) && "number" === typeof g && (this.eles[g].scrollId = b + g, this.eles[g].scrollText = a(b + g).innerHTML, this.eles[g].scrollCutStr = Util.getCutedStr(this.eles[g].scrollText, parseInt(d), c), this.eles[g].marqueeScrollEvent(!1));
						}
			};

			this.getAbsPoint = function (a) {
				for (var b = a.offsetLeft, d = a.offsetTop; a = a.offsetParent;) {
					b += a.offsetLeft, d += a.offsetTop;
				}

				return {
					x: b,
					y: d
				};
			};
		}
		// ELE
		function d(b, d, c, h, opt, index) {
			this.opt = opt || {};
			this.eleUrl = this.htmlEle = void 0;
			this.htmlEleId = b || "";
			if (JQ("#" + this.htmlEleId) && this.opt.IOIsRecordArr === true && this.opt.IORecordIndexArr == index) {
				JQ("#" + this.htmlEleId).addClass("aimin")
			}
			this.focusAttr = d || "className:aim aimon";
			this.blurAttr = c || "className:aim";
			this.moveDirs = h || [-1, -1, -1, -1];
			this.useMarquee = !0;
			this.scrollEle = void 0;
			if (this.opt.scrollEle && JQ(this.opt.scrollEle) && index == 0) {// 初始化高度一下
				var tmpEle = JQ(this.opt.scrollEle);
				var tmpBoxTop = Util.getURLPa(this.opt.scrollEle, location.href, "0", function () {
					return parseInt(tmpEle.css("top"));
				}, true)
				JQ(this.opt.scrollEle).css("top", tmpBoxTop + "px")
			}
			this.scrollText = this.scrollCutStr = this.scrollId = "";

			this.scrollEvent = function () { };

			this.eleOkEvent = function () { };
			// this.eleFocusVipIcon = function () {
			// 	try {
			// 		var _currentTxtList = this.htmlEleId.split('_');
			// 		var _currentIndex = _currentTxtList[1];
			// 		var _currentBoxId = _currentTxtList[0].slice(3);
			// 		var _currentDataList = window["box" + _currentBoxId + "List"];
			// 		var _currentData = null;
			// 		if (this.vod) {
			// 			_currentData = this.vod;
			// 		}
			// 		else {
			// 			if (_currentDataList) {
			// 				if (_currentDataList.vodDataList) {
			// 					_currentData = _currentDataList.vodDataList[_currentIndex];
			// 				} else {
			// 					_currentData = _currentDataList[_currentIndex];
			// 				}
			// 			}
			// 		}
			// 		if (_currentData) {
			// 			parent.vipAutoSubscript(this.htmlEleId, _currentData)
			// 		}
			// 	} catch (e) { }
			// }
			this.focusEvent = function () {
				// _isVipSubscriptIndexTimeout && clearTimeout(_isVipSubscriptIndexTimeout);
				// if (parent.gtvisBack || isIndexPageGoBack) {
				// 	var that = this;
				// 	_isVipSubscriptIndexTimeout = setTimeout(function () {
				// 		that.eleFocusVipIcon();
				// 	}, 1800)
				// 	isIndexPageGoBack = false;
				// } else {
				// 	this.eleFocusVipIcon();
				// }
			};

			this.blurEvent = function () {
				// try {
				// 	var _dom = document.getElementById("vipAutoSubscript");
				// 	if (_dom) {
				// 		this.htmlEle.removeChild(_dom);
				// 	}
				// } catch (e) { }
			};

			this.ok = function () {
				this.eleOkEvent();
				this.eleUrl && (g.location = this.eleUrl);
			};

			this.changeFocus = function (a) {
				a ? this.changeAttr(this.focusAttr) : this.changeAttr(this.blurAttr);

				this.toggleFocusEvent(a);
				this.marqueeScrollEvent(a);
			};

			this.marqueeScrollEvent = function (b) {
				b ? this.scrollCutStr !== this.scrollText && (this.useMarquee ? (this.scrollEle || (this.scrollEle = a(this.scrollId)), null != this.scrollEle && ( //this.scrollEle.innerHTML="<marquee direction='"+this.marDirection+"' scrolldelay='150'>"+this.scrollText+"</marquee>"
					this.scrollEle.innerHTML = "<span id='quee' style='white-space: nowrap;position: relative;'>" + this.scrollText + "&nbsp&nbsp&nbsp&nbsp&nbsp" + this.scrollText + "</span>") && Util.scrollUp()) : this.scrollEvent()) : this.scrollCutStr !== this.scrollText && (this.useMarquee ? (this.scrollEle || (this.scrollEle = a(this.scrollId)), null != this.scrollEle && (this.scrollEle.innerHTML = this.scrollCutStr)) : this.scrollEvent());
			};

			this.toggleFocusEvent = function (a) {
				// a?this.focusEvent():this.blurEvent();
				if (a) {
					this.focusEvent(this.vod);
					if (this.opt.scrollEle) { // 小BOX
						Wrapper.moveScroll(JQ(this.opt.scrollEle), this.htmlEleId, false, {
							isParallel: this.opt.isParallel,
							scrollDir: this.opt.scrollDir,
							scrollRelationEle: null,
							isBox: true
						})
					} else if (Wrapper.opt.scrollEle) {
						Wrapper.moveScroll(JQ(Wrapper.opt.scrollEle), this.htmlEleId, true, {
							isParallel: this.opt.isParallel,
							scrollDir: Wrapper.opt.scrollDir,
							scrollRelationEle: this.opt.scrollRelationEle,
							isBox: false
						});
					}

					try {
						// 自动滚动
						if ("undefined" !== typeof this.pageScroll && this.pageScroll) {
							var _psIsLastLine = false;

							if (this.id + 1 == Wrapper.boxes.length) {
								if (this.X < 2) {
									_psIsLastLine = true;
								} else {
									if (this.curIndex >= (this.X - 1) * this.Y) {
										_psIsLastLine = true;
									} else {
										_psIsLastLine = false;
									}
								}
							}

							var obj = {
								"isLastBox": _psIsLastLine,
								"curId": "box" + this.id + "_" + this.curIndex,
								"hasTitle": this.hasTitle && this.X > 1 && this.curIndex < this.Y,
								"selfHeight": "undefined" !== typeof this["height_line"] ? this["height_line"] : document.querySelector("#" + this.eles[this.curIndex].htmlEleId).offsetHeight
							};

							if ("undefined" !== typeof ps && "function" === typeof ps.scroll) {
								ps.scroll(obj);
							}
						}
					} catch (error) { }
				} else {
					this.blurEvent(this.vod);
				}
			};

			this.changeAttr = function (b) {
				this.htmlEle = a(this.htmlEleId);// 这个时候可能htmlEle不在了还是查询一次稳妥一些;
				b && (b = b.toString().split(":"), null != this.htmlEle && (
					// this.htmlEle[b[0]] = b[1] this.htmlEle.className=b[1]
					JQ("#" + this.htmlEleId).removeClass("aim aimin aimon"),
					JQ("#" + this.htmlEleId).addClass(b[1])
				));
			};
		}

		function a(a) {
			return document.getElementById(a);
		}
		function oldBoxInstance(a, c, g, h, l, n) { for (var p = [], q = a * c, k = 0; k < q; k++)p[k] = new d(h + k, l, n, [0 > k - c ? -1 === g[0] ? -1 : g[0] + ">0" : k - c, 0 === k % c ? -1 === g[1] ? -1 : g[1] + ">0" : k - 1, k + c > a * c - 1 ? -1 === g[2] ? -1 : g[2] + ">0" : k + c, k % c === c - 1 ? -1 === g[3] ? -1 : g[3] + ">0" : k + 1]); g = new b(a, c, g, p, l, n); g.totalEle = a * c; return g }
		function cucAuto(curId, crid) {
			return [-1, -1, -1, -1].map(function (i, index) {
				var left = curId - 1;
				var right = crid ? curId + crid : curId + 1;
				var top = Wrapper.ys;
				var bottom = Wrapper.y;
				if (index == 1 || index == 3) return index == 1 ? left : right;
				// index == 1 ? left : right; // 1左 3右
				if (index == 0 || index == 2) return index == 0 ? top : bottom; // 1左 3右

			});
		}
		let afterRow = 0;
		return {
			$: a,
			Box: b,
			Ele: d,
			oldBoxInstance: oldBoxInstance,
			BoxInstance: function BoxInstance(a, _c, _g, _h, _opt, l, n) { // x y dir  box_
				// x y [] box1_
				var g;
				var c = _c;
				var opt = _opt || {}
				// if(opt.totalEle&&){
				// 	c=
				// }
				if (_g && _g.indexOf("H") > -1 || Wrapper.miny > 0) {
					if (_.isArray(_g)) { //如果是数组
						g = _g
						if (Wrapper.miny == 0) {
							Wrapper.miny = indexs;
							Wrapper.y += indexs; //
							Wrapper.x = indexs;
						}
						Wrapper.miny--;
						if (Wrapper.miny == 0) Wrapper.ys = Wrapper.cid - Wrapper.x + 1; // 纵向
					} else {

						var indexs = _g ? +_g.split("-")[1] : 0;
						if (Wrapper.miny == 0) {
							Wrapper.miny = indexs;
							Wrapper.y += indexs; //
							Wrapper.x = indexs;
						}

						Wrapper.miny--;
						g = cucAuto(Wrapper.cid);
						if (Wrapper.miny == 0) Wrapper.ys = Wrapper.cid - Wrapper.x + 1; // 纵向
					}
				} else if (_g && _g.indexOf("V") > -1 || Wrapper.minx > 0) {

					var indexs = _g ? +_g.split("-")[1] : 0;// 只有组件存在 H-x-y 的形式

					Wrapper.y++; // 纵向

					g = cucAuto(Wrapper.cid, indexs);

					Wrapper.ys = Wrapper.cid; // 纵向

					Wrapper.x = 1;

				} else {
					Wrapper.y++; // 纵向

					g = _g || cucAuto(Wrapper.cid);

					Wrapper.ys = Wrapper.cid; // 纵向

					Wrapper.x = 1;
				}

				var h = _h || "box".concat(Wrapper.cid, "_");

				Wrapper.cid++;
				// var tmpOne = a * c - c;
				for (var p = [], q = a * c, k = 0; k < q; k++) {
					// 上左下右
					var isFinalLast = c == 1 || q == (k + 1); // 最后一行最后一个
					var isFinalFirst = k % c == 0 && k < a; // 第一行第一个
					var final;
					if (opt.h) { // 如果是横向布局且多列就需要加h
						final = [0 > k - c ? -1 === g[0] ? -1 : g[0] + ">0" : k - c, 0 === k % c ? -1 === g[1] ? -1 : g[1] + ">0" : k - 1, k + c > a * c - 1 ? -1 === g[2] ? -1 : g[2] + ">0" : k + c, k % c === c - 1 ? -1 === g[3] ? -1 : g[3] + ">0" : k + 1];
					} else {
						final = [
							0 > k - c ? -1 === g[0] ? -1 : g[0] + `>${afterRow}` : k - c,
							isFinalFirst ? -1 === g[1] ? -1 : g[1] + ">" + Wrapper.lastBoxTotalEle : k - 1,
							k + c > a * c - 1 ? -1 === g[2] ? -1 : g[2] + ">0" : k + c,
							isFinalLast ? -1 === g[3] ? -1 : g[3] + ">0" : k + 1
						];
					}
					p[k] = new d(h + k, l, n, final, opt, k);
				}
				afterRow = a * c - c; // 上一个元素最后一行的第一个索引
				g = new b(a, c, g, p, opt, l, n);
				g.totalEle = a * c;
				Wrapper.lastBoxTotalEle = g.totalEle;
				return g;
			},
		};
	}();

	g.$ = c.$;
	g.eZone = c;
})(window);

(function (g, h) {
	// wrapper
	var c = {
		y: 0,
		lastBoxTotalEle: 0,
		ys: -1,
		x: 1,
		miny: 0,
		cid: 0,
		curBoxId: 0,
		indexId: 0,
		boxes: [],
		keyPressLock: !1,
		dir: h,
		backUrl: h,
		channelBackUrl: h,
		t_num: h,
		channelNumCount: 0,
		tempChannelNum: 0,
		channelNum: 0,
		getCurrentBox: function getCurrentBox() {
			return c.boxes[c.curBoxId];
		},
		resetid: function resetid(n, ys, y, opt) {
			this.cid = n != undefined ? n : 0;
			this.ys = n != undefined ? ys : 0;
			this.y = n != undefined ? y : 0;

			if(opt && opt.indexFixed != null){
				this.indexFixed = opt.indexFixed
			} else if(opt && opt.isEpgView){
				this.getEleRect()
			}
		},
		volumeUpEvent: function volumeUpEvent() { },
		volumeDownEvent: function volumeDownEvent() { },
		volumeMuteEvent: function volumeMuteEvent() { },
		utilityEvent: function utilityEvent() { },
		okEvent: function okEvent() { },
		backEvent: function backEvent() { },
		delEvent: function delEvent() { },
		numTypeEvent: function numTypeEvent() { },
		keyOtherEvent: function keyOtherEvent(a) { },
		pageunload: function () {
			// 页面离开就应该移除所有监听
			// 播放器暂停
			GTVUTILS.$clearAll()
			mp.stop()
			parent.LEAVE && parent.LEAVE();
			Wrapper.unload()
		},
		unload: function () {

		},
		pageload: function () {
			mp.setStatus("init")
			Wrapper.load();
		},
		load: function () {

		},
		getScroll: function () {
			if (this.opt.scrollEle) {
				return JQ(this.opt.scrollEle).css("top").replace("px", "")
			} else {
				return 0
			}
		},
		scrollTop: function () {
			Wrapper.moveScroll(JQ(this.opt.scrollEle), this.htmlEleId, true, {
				isParallel: this.opt.isParallel,
				scrollDir: this.opt.scrollDir,
				scrollRelationEle: this.opt.scrollRelationEle,
				isBox: false
			});
		},
		/**
		 *
		 * @param {*} b 默认聚焦当前盒子id
		 * @param {*} c 默认聚焦当前盒子下的序号
		 * @param {*} a box的数组 new
		 * @param {*} e isLoadRecord 页面是否是返回的且需要记录焦点位置,默认false
		 * @param {*} f 如果页面记录返回，保存焦点的对象obj
		 * @param {*} opts 扩展参数
		 * 		@param {*} scrollEle 滚动组件
		 * 		@param {*} opts 扩展参数
		 * 		@param {*} opts 扩展参数
		 */
		init: function init(b, c, a, opt, e, f) {
			// this.x=1;
			// this.y=0;
			// this.lastBoxTotalEle=0
			// this.ys=-1
			// this.miny=0
			this.curBoxId = parseInt(b || 0);
			this.indexId = c || 0;
			this.clientHeight = document.getElementById("indexWrapperBox") ? document.getElementById("indexWrapperBox").clientHeight : 0;
			this.boxes = a || [];
			this.opt = JQ.extend({}, {
				scrollEle: null,
				scrollDuration: 300
			}, opt);
			var _this$opt = this.opt,
				scrollEle = _this$opt.scrollEle,
				scrollDuration = _this$opt.scrollDuration;
			if (scrollEle) {
				if (typeof scrollEle == "string" && JQ(scrollEle)) {
					this.scrollEle = JQ(scrollEle)[0];
					var Ftop = Util.getURLPa("wrapTop", location.href, "0", function () {
						var tmpTop = parseInt(JQ(scrollEle).css("top"));
						return tmpTop
					}, true)
					// todo replace
					// if(){}

					JQ(scrollEle).css("top", Ftop + "px") // 初始值设置
					GTVUTILS.$emit("pageScrolling", {
						offsetTop: Ftop
					});
					GTVUTILS.$emit("pageScrollEnd", {
						offsetTop: Ftop
					});
				} else {
					this.scrollEle = scrollEle;
				}
			}

			if (this.scrollEle) {
				this.offsetTop = Math.abs(parseInt(this.scrollEle.style.top));
			} else {
				this.offsetTop = 0;
			}

			b = this.boxes.length; //

			for (c = 0; c < b; c++) {
				this.boxes[c].id = c;
			}

			(e = e || !1) && f !== h && (this.curBoxId = parseInt(f.curBoxId), this.indexId = parseInt(f.curIndex));

			if(opt && opt.indexFixed != null){
				this.indexFixed = opt.indexFixed
			} else if(opt && opt.isEpgView){
				this.getEleRect()
			}
			this.boxes[this.curBoxId].changeFocus(this.indexId, !0);
			if (e && f !== h && f.datas !== h)
				for (e = f.datas.length, c = 0; c < b && c < e; c++) {
					this.boxes[c].id === f.datas[c].boxId && (this.boxes[c].curIndex = parseInt(f.datas[c].curIndex), this.boxes[c].darkIndex = parseInt(f.datas[c].darkIndex), this.boxes[c].curPage = parseInt(f.datas[c].curPage));
				}

		},
		pushBox: function pushBox(b) {
			b.id = this.boxes.length;
			this.boxes[this.boxes.length] = b;
		},
		numType: function numType(b) {
			this.numTypeEvent(b);

			if (!!this.goChannelEvent) {
				this.goChannelEvent(b);
			}
		},
		goChannelEvent: function goChannelEvent(b) {
			this.createNumPanel(b);
			this.showChannelNum(b);
			this.t_num != h && clearTimeout(this.t_num);
			this.t_num = setTimeout(this.goToChannel, 2000)
		},
		createNumPanel: function (b) {
			if (null == parent.eZone.$("channelNumPanel")) {
				b = document.createElement("div");
				b.id = "channelNumPanel";
				b.style.position = "absolute";
				b.style.top = "0px";
				b.style.left = "0px";
				b.style.bottom = "0px";
				b.style.right = "0px";
				b.style.zIndex = 20;
				b.style.fontSize = "260px";
				b.style.fontWeight = "bold";
				b.style.color = "#fffff";
				b.style.margin = 'auto';
				b.style.lineHeight = '720px';
				b.style.opacity = "0.5";
				b.style.letterSpacing = "4px";
				b.style.textAlign = "center";
				if (typeof top != "undefined" && top) {
					var w = document.body.getBoundingClientRect().width;
					if (w > 1919 && w < 1920) {
						w = 1920;
					}
					if (w == 1920) {
						b.style.fontSize = "460px";
						b.style.lineHeight = '1080px';
						b.style.zIndex = 50;
					}
				}
				null != document.body && document.body.appendChild(b);
			}
			parent.eZone.$("channelNumPanel").style.display = "block";
		},
		showChannelNum: function showChannelNum(b) {
			this.channelNumCount++;
			if (4 < this.channelNumCount) return !0;
			this.channelNum = this.tempChannelNum = 10 * this.tempChannelNum + b;
			null != parent.eZone.$("channelNumPanel") && (parent.eZone.$("channelNumPanel").innerHTML = this.channelNum);
		},
		goToChannel: function goToChannel(obj) {
			null != parent.eZone.$("channelNumPanel") && (parent.eZone.$("channelNumPanel").style.display = "none");
			var back_url = Util.getBackUrl();

			if (!!this.backUrl) {
				back_url = c.backUrl;
			}

			if (!!this.channelBackUrl) {
				back_url = this.channelBackUrl;
			}

			// 少儿模式按数字键后验证正确继续跳转全屏页，在全屏页按返回需回到标准模式首页
			if (obj && obj.type == "childrenToLive" && typeof (obj.channelNum) != "undefined") {
				c.channelNum = obj.channelNum;
				c.tempChannelNum = obj.channelNum;
				back_url = "";
			}
			var channelNum=c.channelNum;
			c.tempChannelNum=0;
			c.channelNum=0;
      		c.channelNumCount=0;
			var locationHref = window.location.href;
			var enUrl = locationHref.replace(/en\/.+/g, '') + "en/";
			var playLiveUrl = enUrl + "page/chanPlayer.html";
			var turnPlayUrl = enUrl + "common/turnPlay/index.html";

			if (channelNum == 9999) {
				var helpUrl = window.location.href.replace(/en\/.+/g, "") + "en/";
				GO(helpUrl + "page/helpNew.html" + "?&returnUrl=" + escape(back_url));
				return;
			}

			try {
				if (top.userChange != 0 && channelNum == 1111 && window.location.href.indexOf("children_out.html?") == -1) {
					if(typeof parent.sensors != "undefined" && top.gtvEPG && top.gtvEPG.sensors){
						var _loction = window.location;
						var _pageUrl = _loction.href;
						var _pagetype = _pageUrl;
						var _arr = _pagetype.split("en")[1];
						if(_arr){
							var _txt = _loction.pathname;
							_txt = "/en/" + _txt.split("/en/")[1];
							_pagetype = top.gtvEPG.sensors.getPageType(_txt);
						}
						var params = {
							ReferPageName: document.title,
							ReferPageUrl: _pageUrl,
							ReferPageType: _pagetype,
							keyName: '1111'
						}
						parent.sensors.track("ClickRemoteControl", params);
					}
					var helpUrl = window.location.href.replace(/en\/.+/g, "") + "en/";
					GO(helpUrl + "common/playfootball/index.html?code0=XMTBK890618033548034048&code1=XMTBK890618033548034050&code2=XMTBK890618033548034052&code3=XMTBK890618037843001345&code4=XMTBK890618037843001347&returnUrl=" + escape(back_url));
					return;
				}
			} catch (error) {}
			if(!top.channelData[channelNum]){
				top.setBdfrom("clear");
				top.postMessage({type: 'toast', data: '该频道号不存在'}, window.location.href)
				return;
			}else{
				if (window.location.href.split('?')[0].indexOf("chanPlayer.html") > -1) {
					GO(playLiveUrl + "?channelIndex=" + channelNum + "&returnUrl=" + escape(returnUrl));
				} else {
					GO(playLiveUrl + "?channelIndex=" + channelNum + "&returnUrl=" + escape(back_url));
				}
			}
		},
		saveFocus: function saveFocus() {
			for (var b = this.boxes[this.curBoxId], c = this.boxes.length, a = "{curBoxId:" + b.id + ",curIndex:" + b.curIndex + ",datas:[", e = 0; e < c; e++) {
				b = this.boxes[e], a += '{"boxId":' + b.id + ',"indexId":' + b.curIndex + ',"darkIndex":' + b.darkIndex + ',"curPage":' + b.curPage, a += "},";
			}

			a = a.substr(0, a.length - 1);
			a += "]}";
			b = g.location.href.split("?")[0];
			b = b.substring(b.lastIndexOf("/") + 1);
			b = b.substring(0, b.lastIndexOf(".")); -
				1 < b.indexOf("-") && (b = b.replaceAll("-", ""));
			Util.setCookie("lastfoc", b + "-" + a);
		},
		scrollAuto: function scrollAuto({
			realEle,
			ele,
			offsetTop,
			scrollBody,
			scrollEle,
			scrollRect,
			isParallel,
			scrollDir,
			isSuperPage
		}) {
			if (!ele) return;
			if (!scrollEle.contains(ele)) {// 如果聚焦的元素在滚动体之外
				return 0;
			}
			try {
				//如果找到当前焦点元素中有id为boxid+rank的元素，则该元素为LTabList元素的标题焦点元素，此时以LTabList内容为居中位置
				var tabRankId = (parseInt(ele.id.replace("box","").split("_")[0]) + 1) + "rank"
				var tabRankBox = document.getElementById(tabRankId)
				if(tabRankBox != null){
					var centerBoxId = document.getElementById("box" + (parseInt(ele.id.replace("box","").split("_")[0]) + 1) + "_0")
					if(centerBoxId) ele = centerBoxId
				}
				if(!this.indexFixed && !tabRankBox){
					var _LHid = document.getElementById(ele.id.split("_")[0])
					var parentEle = _LHid ? _LHid.parentNode : null
					if(parentEle && (typeof parentEle.className === "string") && (parentEle.className.indexOf("LHorizontal") > -1)){
						ele = parentEle
					}
				}
			} catch (error) {

			}
			var rect = ele.getBoundingClientRect(); // 当前聚焦元素
			var maxScrollY = scrollBody.height;
			if (maxScrollY <= scrollRect.height || !scrollBody) return 0; // 内容没有满一屏，不需要滚动；
			//判断当前是否首屏
			var isFirstIndex = (rect.top + rect.height * 1.1) - offsetTop - scrollRect.top < scrollRect.height
			if (this.indexFixed !== false && isFirstIndex) {
				return 0;
			} else {
				if (scrollDir == 'top') {

					if (rect.top > scrollRect.top && rect.bottom < scrollRect.bottom) {
						offsetTop = offsetTop;
					} else {
					offsetTop += scrollRect.bottom - rect.bottom + (rect.height * 1.1) - scrollRect.height;
					}
				} else {
					if (rect.top > scrollRect.top && rect.bottom < scrollRect.bottom && isParallel) {
						offsetTop = offsetTop;
					} else {
						var header = document.getElementById("epgHeader")
						var headerRect = header.getBoundingClientRect()
						if(header && isFirstIndex && (((rect.top + rect.height / 2) - scrollBody.top - headerRect.height + 20) < document.body.offsetHeight / 2)){// 滚到顶部
							offsetTop = 0
						} else {
							if(isSuperPage){// 靠近顶部显示,但是需要直接是节点ceils还有是方向向下(补充：由于灵活楼层横屏不够高，增加10用于滚动，目前对其他的没有影响)
								if(rect.bottom +10<scrollRect.bottom&&rect.top>scrollRect.top){// 如果当前元素已经在当前视野中就不用滚动
									return offsetTop
								}
								if(Wrapper.lastDirection=="down"||(isSuperPage&&Wrapper.lastDirection=="up"&&ele.querySelectorAll(".Ltitle").length>0)){// 方向向下
									offsetTop += scrollRect.top - rect.top - 15;// 为了多漏一些
								}else if(Wrapper.lastDirection=="up"){// 向上就是居中
									offsetTop += scrollRect.bottom - rect.top - (rect.height) / 1.78 - scrollRect.height / 1.78;
								}
							}else{// 居中显示
								offsetTop += scrollRect.bottom - rect.top - (rect.height) / 2 - scrollRect.height / 2;
							}
						}
					}

				}

			}

			if (!isSuperPage&&maxScrollY - Math.abs(offsetTop) < scrollRect.height) { // 最后一屏与超级电视隔离
				offsetTop = scrollRect.height - maxScrollY;
			}
			if (offsetTop > 0) {
				offsetTop = 0;
			}
			// if (rect.bottom < scrollRect.top && rect.top < scrollRect.top) {
			// 	offsetTop = 0;
			// }

			return offsetTop
		},
		getEleRect() {
			function contains(parent, child) {
				if (!parent || !child) return false
				if (parent === child) return true;
				if (parent.contains) return parent.contains(child);
				let node = child.parentNode;
				while (node !== null) {
					if (node === parent) return true;
					node = node.parentNode;
				}
				return false;
			}
			var firstHalfEles = []
			var header = document.getElementById("epgHeader")
			for (let i = 0; i < this.boxes.length; i++) {
				const eleItem = this.boxes[i];
				if(eleItem.id === 106 || eleItem.id === 101 || eleItem.id === 102) continue;
				for (let idx = 0; idx < eleItem.eles.length; idx++) {
					const element = eleItem.eles[idx];
					var eleDom = document.getElementById(element.htmlEleId)
					if(eleDom && !contains(header, eleDom)){
						var rect = eleDom.getBoundingClientRect()
						if(rect.top < (document.body.offsetHeight / 3) && eleDom.style.display !== "none"){
							firstHalfEles.push(eleDom)
						}
					}
				}
			}
			//判断屏幕上半部分是否有数据 如果上半部分没有数据，那么首屏就需要固定
			this.indexFixed = firstHalfEles.length <= 0
		},
		moveScroll: function moveScroll(scrollEle, boxId, isPageScroll, { isParallel, scrollDir, scrollRelationEle, isBox, indexFixed, isStopScroll }) {
      var boxScroll = null;
      var isSuperPage = typeof isJudgeSuperLingHuo == 'function';
      if (typeof isChargeIndexHtml == 'function') {
        if (isChargeIndexHtml(boxId,scrollEle)) return
      }

    //     // 手动计算滚动
    //     var _dhLingHuoName = isJudgeSuperLingHuo();
    //     var _myBox = document.getElementById(boxId);
    //     var _oll = _myBox.getAttribute('box-scroll');
    //     var _ollPlusX = _myBox.getAttribute('box-scroll-plusX');
    //     var _ollPlusY = _myBox.getAttribute('box-scroll-plusY');
    //     if (_dhLingHuoName!=null && _dhLingHuoName.pageJson == 'super_dynamic_x' && _ollPlusX != "undefined") {
    //       boxScroll =_ollPlusX;
    //     }
    //     else if (_dhLingHuoName!=null && _dhLingHuoName.pageJson == 'super_dynamic_y' && _ollPlusY != "undefined"){
    //       boxScroll =_ollPlusY;
    //     }
    //     else if(_oll != "undefined") {
    //       boxScroll =_oll;
    //     }
    //     if (boxScroll || boxScroll == '0'){
    //       boxScroll = -parseInt(boxScroll);
    //     }
      if(indexFixed != null){
				this.indexFixed = indexFixed
			}
			var _this = this;
			var ele = document.getElementById(boxId); // 当前聚焦元素
			if (scrollRelationEle) { // 关联元素
				ele = JQ(scrollRelationEle)[0]
			}
			var scrollBody = scrollEle && scrollEle[0].getBoundingClientRect(); // 滚动容器的各种尺寸
			var parentEle = scrollEle[0].parentElement; // 滚动元素的父元素
			var scrollRect = parentEle.getBoundingClientRect(); // 父容器
			var currentOffsetTop = Number((scrollEle[0].style.top.toString()).replace('px', ''));
			var offsetTop;
      if (boxScroll || boxScroll == 0) {
        offsetTop = boxScroll;
      } else {
        offsetTop = _this.scrollAuto({
		  realEle:ele,
		  ele:isSuperPage?JQ(ele).closest('.__ceil')[0]:ele,// 原生dom
          offsetTop: currentOffsetTop,
          scrollEle: scrollEle[0],
          scrollBody,// 原生dom
          scrollRect,
          isParallel,
          scrollDir,
		  isSuperPage
        });
      }
      offsetTop = offsetTop.toFixed(1);
			if (currentOffsetTop != offsetTop) {
				if (isPageScroll) {
					if (!isBox) {
            if (typeof isStopScroll =='undefined') {
              GTVUTILS.$emit("pageScrolling", {
                offsetTop: offsetTop,
                scrollEle: scrollEle,
                boxId: boxId
              });
            } else {
              if (typeof superglobalOffsetTop != 'undefined') {
                superglobalOffsetTop = offsetTop;
              }
            }
					}
				}
				scrollEle.stop(true, true).animate({
					top: offsetTop,
				},  300, "", function () {
					if (!isBox) {
						GTVUTILS.$emit("pageScrollEnd", {
							offsetTop: offsetTop,
							scrollEle: scrollEle,
							boxId: boxId
						});
					}
				});
			}
			return offsetTop
		},
		move: function move(b) {
			// b是方向 0 1 2 3
			this.dir = b;
			var c = 0 === b || 1 === b ? -1 : 1,
				a = this.boxes[this.curBoxId];

			if (a) {
				var e = a.eles[a.curIndex].moveDirs[b];

				if (0 === b) {
					var res;
					if (a.eles[a.curIndex] && a.eles[a.curIndex].vod) {
						res = a.upEvent(a.eles[a.curIndex].vod)
					} else {
						res = a.upEvent()
					}
					if (a.autoVerticalFlip && (1 < a.curPage || a.autoCycleFlip))
						if ("X" === a.Arrangement) {
							if (a.curIndex < a.Y) {
								a.pageTurn(c);
								return;
							}
						} else if ("Y" === a.Arrangement && 0 === a.curIndex % a.X) {
							a.pageTurn(c);
							return;
						}
				} else if (1 === b) {
					var res;
					if (a.eles[a.curIndex] && a.eles[a.curIndex].vod) {
						res = a.leftEvent(a.eles[a.curIndex].vod)
					} else {
						res = a.leftEvent()
					}
					if (res == -1) {
						return
					}
					if (a.autoHorizontalFlip && (1 < a.curPage || a.autoCycleFlip))
						if ("X" === a.Arrangement) {
							if (0 === a.curIndex % a.Y) {
								a.pageTurn(c);
								return;
							}
						} else if ("Y" === a.Arrangement && a.curIndex < a.X) {
							a.pageTurn(c);
							return;
						}
				} else if (2 === b) {
					var res;
					if (a.eles[a.curIndex] && a.eles[a.curIndex].vod) {
						res = a.downEvent(a.eles[a.curIndex].vod)
					} else {
						res = a.downEvent()
					}
					if (a.autoVerticalFlip) {
						if (a.focusLast && a.curPage === a.totalPage && (Math.ceil(a.totalEle / a.Y) - 1) * a.Y > a.curIndex && a.curIndex > a.totalEle - 1 - a.Y) {
							a.changeFocus(a.curIndex, !1);
							a.changeFocus(a.totalEle - 1, !0);
							return;
						}

						if (a.curPage < a.totalPage || a.autoCycleFlip)
							if ("X" === a.Arrangement) {
								if (a.lastLineTurn) {
									if (Math.ceil((a.curIndex + 1) / a.Y) === Math.ceil(a.totalEle / a.Y)) {
										a.pageTurn(c);
										return;
									}
								} else {
									if (a.curIndex + a.Y > a.totalEle - 1) {
										a.pageTurn(c);
										return;
									}
								}
							} else if ("Y" === a.Arrangement && (a.curIndex % a.X === a.X - 1 || a.curIndex === a.totalEle - 1)) {
								a.pageTurn(c);
								return;
							}
					}
				} else if (3 === b) {
					var res;
					if (a.eles[a.curIndex] && a.eles[a.curIndex].vod) {
						res = a.rightEvent(a.eles[a.curIndex].vod)
					} else {
						res = a.rightEvent()
					}
					if (res == -1) {
						return
					}
					if ((a.autoHorizontalFlip)) {
						if (a.focusLast && (Math.ceil(a.totalEle / a.X) - 1) * a.X > a.curIndex && a.curIndex > a.totalEle - 1 - a.X) {
							a.changeFocus(a.curIndex, !1);
							a.changeFocus(a.totalEle - 1, !0);
							return;
						}

						if (a.focusLast && (Math.ceil(a.totalEle / a.X) - 1) * a.X > a.curIndex && a.curIndex > a.totalEle - 1 - a.X) {
							a.changeFocus(a.curIndex, !1);
							a.changeFocus(a.totalEle - 1, !0);
							return;
						}

						if (a.curPage < a.totalPage || a.autoCycleFlip)
							if ("X" === a.Arrangement) {
								if (a.curIndex % a.Y === a.Y - 1 || a.curIndex === a.totalEle - 1) {
									a.pageTurn(c);
									return;
								}
							} else if ("Y" === a.Arrangement)

								if (a.lastLineTurn) {
									if (Math.ceil((a.curIndex + 1) / a.X) === Math.ceil(a.totalEle / a.X)) {
										a.pageTurn(c);
										return;
									}
								} else if (a.curIndex + a.X > a.totalEle - 1) {

									a.pageTurn(c);
									return;
								}
					}
				}

				if (e != -1) { // eles moveDirs 上左下右 跳出盒子 盒子初始化的时候就已经把条件限制好了
					// 所以能够盒子移动到其他盒子
					if (typeof e === "string" && e.indexOf('>') > -1) {
						var c = parseInt(e.split('>')[0]);
						var endIndex = parseInt(e.split('>')[1]);

						if (c > this.boxes.length - 1 || this.boxes[c].totalEle <= 0) {
							return;
						}

						a.boxOut(a.curIndex, b);

						if (this.boxes.length > c) {
							if (!this.boxes[c].canSlide && a.canSlide || this.boxes[c].canSlide && a.canSlide && this.boxes[c].slideEle != a.slideEle) {
								a.slideEle.style.display = "none";
							}

							this.boxes[c].boxIn(endIndex, b);
						}
					} else if (typeof e === "number" && a.eles[a.curIndex].moveDirs[b] >= a.totalEle) {
						var c = a.dirs[b];
						if(c>this.boxes.length-1){
							c=this.boxes.length-1
						}
						if (c === -1 || this.boxes[c].totalEle <= 0 || a.curIndex % a.Y >= a.totalEle % a.Y && a.totalEle % a.Y > 0) {
							if (a.Arrangement === "X" && e <= a.X * a.Y && b == 2 && Math.ceil((a.curIndex + 1) / a.Y) < Math.ceil(a.totalEle / a.Y)) {
								a.changeFocus(a.curIndex, false);
								a.changeFocus(a.totalEle - 1, true);
							} else if (a.Arrangement === "Y" && e <= a.X * a.Y && b == 3 && Math.ceil((a.curIndex + 1) / a.X) < Math.ceil(a.totalEle / a.X)) {
								a.changeFocus(a.curIndex, false);
								a.changeFocus(a.totalEle - 1, true);
							}

							return;
						}

						a.boxOut(a.curIndex, b);

						if (this.boxes.length > c) {
							this.boxes[c].boxIn(0, b);
						}
					} else {
						a.move(b);// 盒子范围的移动
					}
				}
			}
		},
		ok: function ok() {
			this.okEvent();
			var curBox = this.boxes[this.curBoxId];
			if (curBox) {
				var res = this.boxes[this.curBoxId].ok(curBox.eles[curBox.curIndex] && curBox.eles[curBox.curIndex].vod);
				//上报推荐位点击事件
				if (curBox.eles[curBox.curIndex] && curBox.eles[curBox.curIndex].vod) {
					main.mainTotId = curBox.eles[curBox.curIndex].htmlEleId;
					var vod = curBox.eles[curBox.curIndex].vod;
					parent.hots.oCurClikcData = vod;
				}
				if (res != "-1" && typeof jump != "undefined" && curBox.eles[curBox.curIndex] && curBox.eles[curBox.curIndex].vod) {
					// 灵活组件
					// 跳转
					if(curBox.eles[curBox.curIndex].vod.tzName){
						curBox.eles[curBox.curIndex].vod.name=curBox.eles[curBox.curIndex].vod.tzName
					}
          if(curBox.eles[curBox.curIndex].vod.contentCode == ""){
            return;
          }
					jump(curBox.eles[curBox.curIndex].vod)
				}
			}
		},
		del: function del() {
			this.delEvent();
		},
		goBackv2: function () {
			var islanjie = this.backEvent()// 执行backEvent
			if (islanjie === true) return;
			this.goBack()// 执行定义好的
		},
		goBack: function goBack() {
			this.backUrl && GO(this.backUrl);
		},
		pageTurn: function pageTurn(b, c) {
			var a = this.boxes[c == h ? this.curBoxId : c];
			a && a.pageTurn(b);
		},
		changeFocus: function changeFocus(b, c) {
			if (this.boxes[this.curBoxId].IOIsRecordArr === true && b != this.curBoxId) {
				var tmpbox = this.boxes[this.curBoxId];
				var tmpIndex = this.boxes[this.curBoxId].curIndex
				setTimeout(function () {
					tmpbox.setIOIsRecord(tmpIndex)
				})
			}
			var a = this.boxes[this.curBoxId];
			a.changeFocus(a.curIndex, !1);
			this.curBoxId = parseInt(b);
			this.boxes[b].changeFocus(c, !0);
		},
		volumeUp: function volumeUp() {
			this.volumeUpEvent();
		},
		volumeDown: function volumeDown() {
			this.volumeDownEvent();
		},
		volumeMute: function volumeMute() {
			this.volumeMuteEvent();
		},
		utility: function utility() {
			this.utilityEvent();
		}
	};
	g.Wrapper = c;
})(window);

(function (g, h) {
	String.prototype.replaceAll = function (c, b) {
		return this.replace(new RegExp(c, "gm"), b);
	};

	var timer = null;
	var ofLeft = 0;
	g.Util = {
		//v2.0
		params: {},
		paramsKeep: {},// 单页面使用
		scrollUp: function scrollUp() {
			var quee = document.getElementById("quee");
			var thisLenght = quee.offsetWidth;
			ofLeft = 0;

			if (timer != null) {
				clearInterval(timer);
			}

			timer = setInterval(function () {
				if (Math.abs(quee.offsetLeft) > thisLenght / 2 + 4) {
					quee.style.left = 0;
					ofLeft = 0;
				} else {
					ofLeft += 3;
					quee.style.left = -ofLeft + "px";
				}
			}, 100);
		},
		queryURLPaClear: function () {
			g.Util.params = {};
		},
		getURLPa: function getURLPa(param, url, _moren, updateFunction, isKeep) {// isKeep用户保持单页面所需要切换一次页面执行方法就会清空
			// v2.0 只能用一次 然后返回默认值 单页面处理返回逻辑
			let index = -1
			if (isKeep) {
				if (g.Util.paramsKeep[param]) {
					index = 2;
				}
				g.Util.paramsKeep[param] = {
					key: param,
					updateFunction: updateFunction,
					isKeep: isKeep
				};
			} else {
				if (g.Util.params[param]) {
					index = 2;
				}
				g.Util.params[param] = {
					key: param,
					updateFunction: updateFunction,
					isKeep: isKeep
				};
			}

			var moren = "";
			if (_moren !== undefined) {
				moren = _moren
			}
			var params = url.substr(url.indexOf("?") + 1).split("&");
			if (params != null) {
				for (var i = 0; i < params.length; i++) {
					var strs = params[i].split("=");
					if (index > -1 && updateFunction) { // 避免原来的写法导致异常
						return moren;
					}
					if (strs[0] == param) {
						return strs[1];
					}
				}
			}
			return moren;
		},
		getBackUrl: function getBackUrl(isescape) {
			var a = window.location.href;
			a = Util.changeURLArg(a, "boxId", Wrapper.curBoxId);
			a = Util.changeURLArg(a, "indexId", Wrapper.boxes[Wrapper.curBoxId] && Wrapper.boxes[Wrapper.curBoxId].curIndex); // v2.0
			for (var index in g.Util.params) {
				var element = g.Util.params[index];
				if (typeof element.updateFunction == "function") {
					try {
						a = Util.changeURLArg(a, element.key, element.updateFunction());
					} catch (e) {
						console.error(e)
					}
				}
			}
			for (var index in g.Util.paramsKeep) {
				var element = g.Util.paramsKeep[index];
				if (typeof element.updateFunction == "function") {
					try {
						a = Util.changeURLArg(a, element.key, element.updateFunction());
					} catch (e) {
						console.error(e)
					}
				}
			}
			if (isescape) {
				return escape(a)
			}
			return a;
		},
		changeURLArg: function changeURLArg(c, b, d) {
			var pattern = b + '=([^&]*)';
			var replaceText = b + '=' + d;

			if (c.match(pattern)) {
				var tmp = '/(' + b + '=)([^&]*)/gi';
				tmp = c.replace(eval(tmp), replaceText);
				return tmp;
			} else {
				if (c.length === c.indexOf("?") + 1) {
					c = c.substring(0, c.indexOf("?"));
				}

				if (c.length === c.indexOf("&") + 1) {
					c = c.substring(0, c.indexOf("&"));
				}

				if (c.match('[\?]')) {
					return c + '&' + replaceText;
				} else {
					return c + '?' + replaceText;
				}
			}

		},
		getSliceList: function getSliceList(c, b, d) {
			var a = [];
			b = (b - 1) * d;

			for (var e = c.length, f = 0; f < d && f + b < e; f++) {
				a[f] = c[b + f];
			}

			return a;
		},
		getParamObj: function getParamObj(c) {
			var b,
				d,
				a,
				e,
				f = {};
			c = c ? c.replace(/[^\?]*\?/, "") : g.location.search.substring(1);
			var h = c.split("&");
			a = 0;

			for (e = h.length; e > a; a++) {
				c = h[a], b = c.indexOf("="), -1 !== b && (d = c.substr(b + 1), d = decodeURIComponent(d), f[c.substr(0, b)] = d);
			}

			return f;
		},
		getByteLength: function getByteLength(c) {
			if (c) c.constructor != String && (c = c.toString());
			else return 0;
			var b = 0,
				d = c.length;

			if (c) {
				for (var a = 0; a < d; a++) {
					255 < c.charCodeAt(a) ? b += 2 : 119 === c.charCodeAt(a) || 109 === c.charCodeAt(a) || 87 === c.charCodeAt(a) || 77 === c.charCodeAt(a) ? b += 2 : b++;
				}

				return b;
			}

			return 0;
		},
		getCutedStr: function getCutedStr(c, b, d) {
			if (c) c.constructor != String && (c = c.toString());
			else return "";
			c = c.replace(new RegExp("&nbsp;", "gm"), " ");

			for (var a = "", e = 0, f, g = 0; f = c.charAt(g); g++) {
				if (f.match(/^[\u0400-\u04FF\u0600-\u06FF]+$/) != null) { //如果是阿拉伯语俄语按照一个字符算
					e += 1
				} else {
					e += null != f.match(/[^\x00-\xff]/) ? 2 : 1
				};
				if ("W" === f || "w" === f || "m" === f || "M" === f) e += 1;
				if (e > b) break;
				a += f;
			}

			return !d || "" === a || e <= b ? a : a + "...";
		},
		completionZero: function completionZero(c, b) {
			"string" !== typeof c && (c = c.toString());
			return b.substring(0, b.length - c.length) + c;
		},
		isArray: function isArray(c) {
			var b = "[object Array]" === Object.prototype.toString.call(c);
			b || null == c || (b = c.constructor == Array);
			return b;
		},
		isExist: function isExist(c) {
			return null != c && c != h && "" != c && "null" != c && "undefined" != c;
		},
		createJSONP: function createJSONP(c, b) {
			var d = document.createElement("script");
			d.type = "text/javascript";
			d.id = c;
			d.src = b;
			document.getElementsByTagName("HEAD")[0].appendChild(d);
		},
		delJSONP: function delJSONP(c) {
			c = document.getElementById(c);
			document.head.removeChild(c);
		},
		createIframe: function createIframe(c, b) {
			var d = document.getElementById(iframeId);
			null == d ? (d = document.createElement("iframe"), d.id = iframeId, d.width = "0px", d.left = "0px", d.style.display = "none", d.src = b, null != document.body && document.body.appendChild(d)) : d.src = b;
		},
		delIframe: function delIframe(c) {
			c = document.getElementById(c);
			document.body.removeChild(c);
		},
		createSlideEle: function createSlideEle(c, b, d, a) {
			var e = eZone.$(c);
			null == e && (e = document.createElement("div"), e.id = c, e.className = b, e.style.left = "0px", e.style.top = "0px", e.style.width = "0px", e.style.height = "0px", e.style.display = "none", e.style.transitionDuration = d, a = a || document.body, null != a && a.appendChild(e));
			return e;
		},
		ajax: function ajax() {
			var c = arguments[0] || "",
				b = arguments[1] || "",
				d = arguments[2] || "",
				a,
				e;
			4 === arguments.length && (a = arguments[3] || "");
			e = g.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");

			e.onreadystatechange = function () {
				4 == e.readyState && 200 == e.status && "function" === typeof d && d(e.responseText);
			};

			"function" === typeof d ? e.open(c, b, !0) : e.open(c, b, !1);
			"GET" === c ? e.send() : "POST" === c && (e.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"), e.send(a));
			return e.responseText;
		},
		setCookie: function setCookie(c, b) {
			var d = new Date();
			d.setTime(d.getTime() + 6048E5);
			document.cookie = c + "=" + escape(b) + ";expires=" + d.toGMTString() + ";path=/";
		},
		getCookie: function getCookie(c) {
			var b = null;
			null != document.cookie && 0 < document.cookie.length && (b = document.cookie.match(new RegExp("(^| )" + c + "=([^;]*)(;|$)")));
			return null != b ? unescape(b[2]) : null;
		},
		delCookie: function delCookie(c) {
			var b = new Date();
			b.setTime(b.getTime() - 1E4);
			document.cookie = c + "=;expires=" + b.toGMTString() + ";path=/";
		},
		animate: function animate(c, b) {
			function d() {
				var h = 1 - (Math.max(0, f + b.duration - +new Date()) / b.duration || 0),
					m = function m() {
						if (null != e.leftstart && null != e.leftend) {
							var a = (e.leftend - e.leftstart) * h + e.leftstart;
							c.style.left = a + "px";
						}

						null != e.topstart && null != e.topend && (a = (e.topend - e.topstart) * h + e.topstart, c.style.top = a + "px");
					};

				1 === h ? (m(), a && g.cancelAFrame(a)) : (m(), a = g.requestAFrame(d));
			}

			var a,
				e = {
					leftstart: null,
					leftend: null,
					topstart: null,
					topend: null
				};
			null == b.left || isNaN(c.offsetLeft) || (e.leftstart = parseInt(c.offsetLeft), e.leftend = b.left);
			null == b.top || isNaN(c.offsetTop) || (e.topstart = parseInt(c.offsetTop), e.topend = b.top);
			var f = +new Date();

			g.requestAFrame = function () {
				return g.requestAnimationFrame || g.webkitRequestAnimationFrame || g.mozRequestAnimationFrame || g.oRequestAnimationFrame || function (a) {
					return g.setTimeout(a, 1E3 / 60);
				};
			}();

			g.cancelAFrame = function () {
				return g.cancelAnimationFrame || g.webkitCancelAnimationFrame || g.mozCancelAnimationFrame || g.oCancelAnimationFrame || function (a) {
					g.clearTimeout(a);
				};
			}();

			a = g.requestAFrame(d);
		}
	};
})(window);

(function (g, h) {
	var c = {
		keyDown: function keyDown(b) {
			b = b || g.event;
			b = b.keyCode || b.which || b.charCode;

			// if (b == 768) { // 播放器事件不能拦截
			// 	Wrapper.utility();
			// 	if (typeof eventJson != "undefined") {
			// 		EVENT.tvEvent = JSON.stringify(eventJson);
			// 		window.GTVUTILS && GTVUTILS.$emit("mediaEvent", eventJson)
			// 	} else {
			// 		EVENT.tvEvent = Utility.getEvent();
			// 		window.GTVUTILS && GTVUTILS.$emit("mediaEvent", JSON.parse(EVENT.tvEvent))
			// 	}
			// 	return 0
			// }
			if (!Wrapper.keyPressLock) {
				switch (b) {
					case 48:
					case 49:
					case 50:
					case 51:
					case 52:
					case 53:
					case 54:
					case 55:
					case 56:
					case 57:
						Wrapper.numType(b - 48);
						break;
					case 87:
					case 38:
						Wrapper.lastDirection="up";
						Wrapper.move(0);
						Wrapper.lastDirection=undefined;
						break;

					case 65:
					case 37:
						Wrapper.lastDirection="left";
						Wrapper.move(1);
						Wrapper.lastDirection=undefined;
						break;

					case 83:
					case 40:
						Wrapper.lastDirection="down";
						Wrapper.move(2);
						Wrapper.lastDirection=undefined;
						break;

					case 68:
					case 39:
						Wrapper.lastDirection="right";
						Wrapper.move(3);
						Wrapper.lastDirection=undefined;
						break;

					case 13:
						Wrapper.ok();
						break;

					case 32:
					case 8:
						Wrapper.goBackv2(true);
						break;

					case 280:
					case 287:
						Wrapper.del();
						break;

					case 188:
					case 33:
						Wrapper.pageTurn(-1);
						break;
					case 190:
					case 34:
						Wrapper.pageTurn(1);
						break;
					case 187: // +
					case 259:
						Wrapper.volumeUp();
						break;
					case 189: // -
					case 260:
						Wrapper.volumeDown();
						break;
					case 192: // `
					case 261:
						Wrapper.volumeMute();
						break;
					default:
						Wrapper.keyOtherEvent(b);
						break;
				}
				return 0;
			}
		},
		bindKey: function bindKey() {
			document.onkeydown = this.keyDown;
		}
	};
	c.bindKey();
	g.Control = c;
})(window);
